<template>
  <div>
    <el-tabs v-model="activeName" @tab-click="getPageList">
      <el-tab-pane label="未审核" name="4"></el-tab-pane>
      <el-tab-pane label="未通过" name="5"></el-tab-pane>
    </el-tabs>
    <!-- 展示试卷状态列表 -->
    <el-table ref="paperTable" :data="this.list" style="width: 100%">
      <el-table-column prop="gmtModified" label="日期" width="180">
      </el-table-column>
      <el-table-column prop="name" label="试卷名称" width="180">
      </el-table-column>
      <el-table-column prop="remark" label="备注" width="180">
      </el-table-column>
      <!-- <el-table-column prop="statusName" label="状态" width="100" align="center">
        <template slot-scope="scope">
          <el-tag :type="scope.row.status === '4' ? 'success' : 'danger'" disable-transitions>{{scope.row.statusName}}</el-tag>
        </template>
      </el-table-column> -->
      <el-table-column prop="prop" label="操作" width="width">
        <template slot-scope="{row,$index}">
          <el-button type="warning" icon="el-icon-view" size="mini" @click="showPaperDetail(row)">查看</el-button>
          <el-button type="danger" icon="el-icon-upload" size="mini" class="edit" @click="paperIsPass(row,true)">通过</el-button>
          <el-button v-if="row.status=='4'" type="danger" icon="el-icon-circle-close" size="mini" @click="paperIsPass(row,flase)">不通过</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  name:'paper_updateState',
  data() {
    return {
      //当前看中状态
      activeName: '4',
      //处于该状态的试卷列表
      list:[],
    }
  },
  mounted(){
    this.getPageList();
  },
  methods: {
    //查看试卷，跳转函数
    showPaperDetail(row){
      // 内部界面转换为整张试卷所在的界面
      // 跳转到该试卷所在的界面
      this.$router.push({
        name:'PaperDetail',
        query:{
            paper_info:JSON.stringify(row)
        },
      })
    },
    //审核是否通过
    async paperIsPass(row,flag){
      let result = await this.$API.paper_updateState.passPaper(row.id,flag);
      if(result.code==20000){
        if(flag){
          this.$message({
            type: 'success',
            message: '审核成功!'
          });
        }else{
          this.$message({
            type: 'warning',
            message: '已经不通过!'
          });
        }
        this.getPageList();
      }
    },
    //展示列表
    async getPageList(){
      let result = await this.$API.paper_updateState.getAllNoPassedPaper(this.activeName);
      if(result.code==20000){
        this.list = result.data.papers;
      }
    }
  },
}
</script>

<style>
.edit {
  color: #fff;
  background-color: rgb(48, 235, 148);
  border-color: rgb(49, 248, 155);
}
.edit:hover,
.edit:focus {
  background: var(--el-button-hover-color);
  border-color: var(--el-button-hover-color);
  color: var(--el-button-font-color);
}
</style>